import rclpy
from rclpy.node import Node
from tf2_ros import TransformListener
from tf2_ros.buffer import Buffer
from tf2_ros import TransformException

rclpy.init()
node = Node('transform_listener_node')
tf_buffer = Buffer()
tf_listener = TransformListener(tf_buffer, node)

def transform_listener_callback():
    try:
        # get_now = node.get_clock().now()
        now = rclpy.time.Time()
        trans = tf_buffer.lookup_transform('B', 'P', now)
        print("transform: ",trans)
    except TransformException as e:
        print("Could not transform 'B' to 'P': ",e)

node.create_timer(1.0, transform_listener_callback)

rclpy.spin(node)

node.destroy_node()